package com.weslide.weslideapp.parser;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.weslide.weslideapp.pojo.ao.LoginAO;
import com.weslide.weslideapp.pojo.ao.RegisterAO;

public class RegisterParser {
	private LoginAO registerAO = new LoginAO();

	public void parser(String jsonString) throws JSONException {
		JSONArray jsonArray = new JSONArray(jsonString);
		JSONObject statusJsonObject = jsonArray.getJSONObject(0);
		registerAO.setStatus(statusJsonObject.getString("status"));
		if (registerAO.getStatus().equals("1")) {
			JSONObject dataJsonObject = jsonArray.getJSONObject(1);
			registerAO.setUserId(dataJsonObject.getString("user_id"));
			registerAO.setScore(dataJsonObject.getString("score"));
			registerAO.setName(dataJsonObject.getString("name"));
			registerAO.setPhone(dataJsonObject.getString("phone"));
			registerAO.setInviteCode(dataJsonObject.getString("invitecode"));
			registerAO.setLevelId(dataJsonObject.getString("level_id"));
			registerAO.setLevelName(dataJsonObject.getString("level_name"));
			registerAO.setSaveMoney("0.0");
		}
	}

	public LoginAO getData() {
		return this.registerAO;
	}
}
